// pages/game/game.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    title: "",
    length:"",
    content:""
  },

  recommend: function (e) {
    // var data = this.data.poem;
    let tuser = wx.getStorageSync('user')
    var that = this;
    wx.request({
      url: 'http://localhost:8080/index/index1',
      method: 'POST',
      header: {
        // "content-type":'application/x-www-form-urlencoded'
        'content-type': 'application/json' // 默认值
      },
      data: tuser.id,
      success: function (res) {
        var message = res.data;
        // console.log(res.data);
        // console.log(res.data.length);
        if (message == null) {
          var toastText = '数据获取失败';
          wx.showToast({
            title: toastText,
            icon: '',
            duration: 2000
          });
        } else {
          that.setData({
            length:res.data.length,
            title: res.data[res.data.length-1],
            message:res.data,
          })
        }
      }
    })
  },

  // 跳转到具体内容页并把具体内容作为参数传到二级页面
  gotoContent: function (e) {
    //获取绑定的参数
    var data = e.currentTarget.dataset;
    wx.navigateTo({
      url: '/pages/poerty_content/poerty_content?id=' + data.title,
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    // 刷新
    this.recommend()
  },

   /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    this.onLoad()
  },

})